package com.raos.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * HelloJob
 * 自定义job，实现quartz Job接口，执行具体的任务
 * 当前任务：打印当前的执行时间 例如 2019-11-23 00:00:00
 *
 * @author raos
 * @email 991207823@qq.com
 * @date 2021/10/01 20:03
 */
public class HelloJob implements Job {

    private Logger logger = LoggerFactory.getLogger(HelloJob.class);

    private SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 需要执行业务逻辑写在这
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Date date = new Date();
        String formatDate = sf.format(date);
        logger.info("现在的时间是：{}", formatDate);
        logger.info("Hello Quartz");
    }

}
